package visao.professor;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.border.EmptyBorder;

import modelagem.Professor;

import com.towel.el.annotation.AnnotationResolver;
import com.towel.swing.table.ObjectTableModel;

import controle.professor.AcoesBuscaProfessor;

@SuppressWarnings("serial")
public class BuscadeProfessor extends JDialog{

	private final JPanel contentPanel = new JPanel();
	private JTable table;
	private JTextField textNome;
	private ObjectTableModel<Professor> modeloTabela;
	private AnnotationResolver aR;
	private interfaceProfessor ip;
	private AcoesBuscaProfessor AcoesBuscaProfessor;

	
	public BuscadeProfessor(interfaceProfessor ip) {
		this.ip = ip;
		AcoesBuscaProfessor = new AcoesBuscaProfessor(this);
		setBounds(100, 100, 450, 300);
		this.setSize(505, 400);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
		this.setModal(true);
		this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		aR = new AnnotationResolver(Professor.class);
		modeloTabela = new ObjectTableModel<Professor>(aR, "nome");
		
		JLabel lblBuscarNome = new JLabel("Buscar Nome:");
		lblBuscarNome.setBounds(10, 11, 106, 14);
		contentPanel.add(lblBuscarNome);
		
		table = new JTable(modeloTabela);
		
		table.getColumnModel().getColumn(0).setWidth(12);
		
		JScrollPane sP = new JScrollPane(table);
		sP.setBounds(10, 42, 467, 289);
		contentPanel.add(sP, JTable.RIGHT_ALIGNMENT);
		
		textNome = new JTextField();
		textNome.setBounds(97, 8, 380, 20);
		contentPanel.add(textNome);
		textNome.setColumns(10);
		{
			JPanel buttonPane = new JPanel();
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER, 50, 5));
			
			JButton btnSelecionar = new JButton("Selecionar");
			btnSelecionar.addActionListener(AcoesBuscaProfessor);
			btnSelecionar.setName("Selecionar");
			buttonPane.add(btnSelecionar);
			
			JButton btnBuscar = new JButton("Buscar");
			btnBuscar.setName("Buscar");
			btnBuscar.addActionListener(AcoesBuscaProfessor);
			buttonPane.add(btnBuscar);
			
			JButton btnCancelar = new JButton("Fechar");
			btnCancelar.setName("Cancelar");
			btnCancelar.addActionListener(AcoesBuscaProfessor);
			buttonPane.add(btnCancelar);
		}
	}


	public JTable getTable() {
		return table;
	}


	public void setTable(JTable table) {
		this.table = table;
	}


	public JTextField getTextField() {
		return textNome;
	}


	public void setTextField(JTextField textField) {
		this.textNome = textField;
	}


	public ObjectTableModel<Professor> getModeloTabela() {
		return modeloTabela;
	}


	public void setModeloTabela(ObjectTableModel<Professor> modeloTabela) {
		this.modeloTabela = modeloTabela;
	}


	public AnnotationResolver getaR() {
		return aR;
	}


	public void setaR(AnnotationResolver aR) {
		this.aR = aR;
	}


	public interfaceProfessor getIp() {
		return ip;
	}


	public void setIp(interfaceProfessor ip) {
		this.ip = ip;
	}


	public AcoesBuscaProfessor getAcoesBuscaProfessor() {
		return AcoesBuscaProfessor;
	}


	public void setAcoesBuscaProfessor(AcoesBuscaProfessor acoesBuscaProfessor) {
		AcoesBuscaProfessor = acoesBuscaProfessor;
	}


	public JPanel getContentPanel() {
		return contentPanel;
	}
}

